package com.javajun.endofterm.controller;

import com.javajun.endofterm.entity.Domitory;
import com.javajun.endofterm.entity.Student;
import com.javajun.endofterm.service.DomitoryService;
import com.javajun.endofterm.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author: Xiong Limin
 * Date: 2020-12-02-5:26 下午
 */
@RequestMapping(value = "/page/table")
@Controller
public class TableController {

    @Autowired
    private DomitoryService domitoryService;

    @Autowired
    private StudentService studentService;

    @RequestMapping(value = "/domitory-add")
    public String domitoryAddView() {
        return "page/table/domitory-add";
    }

    @RequestMapping(value = "/domitory-edit")
    public String domitoryEdit(Integer id, ModelMap map) {
        Domitory domitory = domitoryService.findById(id);
        map.put("model", domitory);
        return "page/table/domitory-edit";
    }

    @RequestMapping("/expressDelivery-add")
    public String expressDeliveryAdd() {
        return "page/table/expressDelivery-add";
    }

    @RequestMapping("/student-add")
    public String studentAdd() {
        return "page/table/student-add";
    }

    @RequestMapping(value = "/student-edit")
    public String studentEdit(Integer id, ModelMap map) {
        Student student = studentService.findById(id);
        map.put("model", student);
        return "page/table/student-edit";
    }
}
